import {reqDetailSwiper,reqDetailColor} from '@/api'

export default {
    actions:{
        //轮播图
        async getDetailSwiper({commit}){
            let result = await reqDetailSwiper();
            // console.log(result)
            if(result.code === 200){
                commit('SAVE_DETAIL_SWIPER_LIST',result.detail.data.swiper)
            }else{
                alert('有点小错误')
            }
        },
        //手机详情颜色
        async getDetailColor({commit}){
            let result = await reqDetailColor();
            console.log(result)
            if(result.code === 200){
                commit('SAVE_DETAIL_COLOR',result.detail.data.colorList.slice(1,4))
            }
        }
    },
    mutations:{
        SAVE_DETAIL_SWIPER_LIST(state,swiperList){
            state.detailSwiperList = swiperList
        },
        SAVE_DETAIL_COLOR(state,detailColorList){
            state.detailColorList = detailColorList
        }
    },
    state:{
        detailSwiperList:[],
        detailColorList : [],
    },
    getters:{}
}